package com.atguigu.statics;

import com.atguigu.Calculator2;

/**
 * @author Cheng-02
 * @version V1.0
 * @Package com.atguigu.statics
 * @date 2024/4/22 下午7:13
 */
//代理类
public class StaticProxyCalculator2 implements Calculator2 {

    private Calculator2 calculator2;
    //使用构造函数传入目标
    public StaticProxyCalculator2(Calculator2 target){
        this.calculator2 =target;
    }
    @Override
    public int add(int i, int j) {
        //非核心业务，中介使用
        System.out.println("i = " + i + ", j = " + j);

        //调用目标
        int result = calculator2.add(1, 1);
        System.out.println("result = " + result);
        return 0;
    }

    @Override
    public int sub(int i, int j) {
        return 0;
    }

    @Override
    public int mul(int i, int j) {
        return 0;
    }

    @Override
    public int div(int i, int j) {
        return 0;
    }
}
